package com.hundsun.yr.universal.p2p.utils;

import android.text.TextUtils;

import com.hundsun.yr.universal.library.utils.HsDateUtils;
import com.hundsun.yr.universal.library.utils.HsNumberUtils;
import com.hundsun.yr.universal.library.utils.MathUtils;

import java.util.Calendar;
import java.util.Date;

public class RefundDayUtils {
	/**
	 * 时间标识 1国庆，2新年，3清明节(2017)，4劳动节(2017)，5端午节(2017)6国庆(2017)
	 */
	public static int tagType=0;
	
	/**
	 * 预计还款计算
	 * @param isDay 是否未天（true 是）
	 * @param count 
	 * @return
	 */
	public static String returnDay(String refundWay,boolean isDay,int count){
		Calendar calendar =Calendar.getInstance();
		Date date =calendar.getTime();
		String time;
		tagType=0;
		if(TextUtils.equals(refundWay, "2") || TextUtils.equals(refundWay, "3") || TextUtils.equals(refundWay, "4")){
			time="每月"+HsDateUtils.timeformat("dd", new Date())+"号";
		}else{
			if(isDay){
				long longTime =date.getTime()+MathUtils.string2long(MathUtils.multiply("86400000",String.valueOf(count)));
				time=HsDateUtils.timeformat(HsDateUtils.farmat_date_3, longTime);
			}else{
				int year =calendar.get(Calendar.YEAR);
				int month=calendar.get(Calendar.MONTH)+1;
				int day =calendar.get(Calendar.DAY_OF_MONTH);
				time=HsNumberUtils.numberFormat("00",(year+(month+count)/12))+"-"+"-"+HsNumberUtils.numberFormat("00",((month+count-1)%12+1))+"-"+HsNumberUtils.numberFormat("00",day);
			}
			
			
			if(time.contains("10-01")||time.contains("10-02")||time.contains("10-03")||time.contains("10-04")||time.contains("10-05")||time.contains("10-06")||time.contains("10-07")){
				tagType=1;
			}
			
			if(time.contains("2017-01-27")||time.contains("2017-01-28")||time.contains("2017-01-29")||time.contains("2017-01-30")||time.contains("2017-01-31")||time.contains("2017-02-01")||time.contains("2017-02-02")
					||time.contains("2018-02-15")||time.contains("2018-02-16")||time.contains("2018-02-17")||time.contains("2018-02-18")||time.contains("2018-02-19")||time.contains("2018-02-20")||time.contains("2018-02-21")
					||time.contains("2019-02-04")||time.contains("2019-02-05")||time.contains("2019-02-06")||time.contains("2019-02-07")||time.contains("2019-02-08")||time.contains("2019-02-09")||time.contains("2019-02-10")){
				tagType=2;
			}
			if(time.contains("2017-04-02")||time.contains("2017-04-03")||time.contains("2017-04-04")){
				tagType=3;
			}
			if(time.contains("2017-04-29")||time.contains("2017-04-30")||time.contains("2017-05-01")){
				tagType=4;
			}
			if(time.contains("2017-05-28")||time.contains("2017-05-29")||time.contains("2017-05-30")){
				tagType=5;
			}
			if(time.contains("2017-10-08")){
				tagType=6;
			}
		}
		
		return time;
	}
	
	/**
	 * 还款提示
	 * @param type 1国庆，2新年，3清明节(2017)，4劳动节(2017)，5端午节(2017)6国庆(2017)
	 * @return
	 */
	public static String showMsg(int type){
		if(type==1){
			return "预计还款日在国庆期间，请更改借款期限避开长假";
		}else if(type==2){
			return "预计还款日在春节期间，请更改借款期限避开长假";
		}else if(type==3){
			return "预计还款日在清明节期间，请更改借款期限避开长假";
		}else if(type==4){
			return "预计还款日在劳动节期间，请更改借款期限避开长假";
		}else if(type==5){
			return "预计还款日在端午节期间，请更改借款期限避开长假";
		}else if(type==5){
			return "预计还款日在国庆节期间，请更改借款期限避开长假";
		}else{
			return "";
		}
	}
}
